home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Leonardo the Inventor
/
Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso
/
LEOWINMV
/
DATABASE.DIR
/
00083_Script_DB SCROLL
< prev
next >
Wrap
Text File
|
1996-03-28
|
8KB
|
224 lines
-- ---------------------------------------------------------------
-- HANDLERS scrollArea, updateScrollBar, and updateBrowser are used
-- when the user scrolls by clicking the square in the scroll bar.
-- ---------------------------------------------------------------
-- ---------------------------------------------------------------
-- Handler scrollArea moves the scroll square and updates the text
-- in the browser when the user scrolls by clicking the square in
-- the scroll bar.
on scrollArea clickV
global browserTopLine, browserScroll
-- cleardatabase
unhiliteClickedTopic
updateScrollArea(clickV)
updateBrowser
updateStage
repeat while the mouseDown
scrollArea(the mouseV)
end repeat
end
-- --------------------------------------------------------------
-- Handler resetScrollArea moves the scroll square when the user
-- scrolls by clicking the square in the scroll bar.
on resetScrollArea
global origScrollPos, browserScroll
set the locV of sprite browserScroll = origScrollPos
-- updateStage done elsewhere
end
-- --------------------------------------------------------------
-- Handler updateScrollArea moves the scroll square when the user
-- scrolls by clicking the square in the scroll bar.
on updateScrollArea clickV
global browserScroll
-- the locV of sprite scrollSprite will be constrained by 'the
-- constraint of sprite scrollSprite' set in initializeData.
set the locV of sprite browserScroll = clickV
-- updateStage done elsewhere
end
-- --------------------------------------------------------------
-- Handler updateBrowser updates the text in the browser when the
-- user scrolls by clicking the square in the scroll bar.
on updateBrowser
global constraintScrollBar, browserTopics, numVisibleTopics, browserTopLine
global browserScroll, numLinesPerBrowserEntry
set scrollHeight = the height of sprite constraintScrollBar
set V = the locV of sprite browserScroll - the top of sprite constraintScrollBar
set numTopics = the number of lines in browserTopics
set browserTopLine = integer (V * numTopics / scrollHeight)
set lastLine = numTopics - numVisibleTopics
if (browsertopline >= lastLine) then
set browserTopLine = lastLine
end if
if (browserTopLine = 0) then
set browserTopLine = 1
end if
setBrowserText
end
-- ---------------------------------------------------------------
-- Handler scrollBrowser is used when the user scrolls by clicking
-- the up and down arrows of the browser. It (1) clears the stage
-- from any info pertaining to the previous topic, scrolls the text
-- in the browser, (2) scrolls the browser in the given direction
-- (1 = scrollDown, -1 = scrollUp).
-- The parameter clickedSprite is passed to make sure that the mouse
-- has not moved when scrolling continues.
on scrollBrowser clickedSprite, direction
global browserTopLine, browserScroll, numVisibleTopics, browserTopics, numVisibleLines
-- clearDatabase
unhiliteClickedTopic
set numLines = the number of lines in browserTopics - numVisibleLines
scroll(clickedSprite, direction, numLines)
repeat while (the mouseDown)
if (the mouseCast = the castNum of sprite clickedSprite) then
scroll(clickedSprite, direction, numLines)
end if
end repeat
end
-- ---------------------------------------------------------------
-- Handler scroll:(1) updates the topLine of the given field to be
-- scrolled (browser or text) (2) moves the given scroll square to
-- correspond to the text and (3) updates the text in the given field.
-- The handler takes the following parameters:
-- (A) clickedSprite (the original sprite that was clicked to start the
-- scrolling. This is to make sure that if the mouse remains down
-- but moves from over a scrolling arrow, the text does not continue
-- scrolling)
-- (B) direction (1 = scrollDown, -1 = scrollUp)
-- (C) numLines (the number of lines in the text to be browsed)
on scroll clickedSprite, direction, numLines
global browserTopLine, browserScroll, numVisibleTopics, browserTopics
set browserTopLine = updateBrowserTopLine(direction, numLines)
moveScrollSquareToMatchText
setBrowserText
end
-- ---------------------------------------------------------------
-- Handler updateBrowserTopLine
on updateBrowserTopLine amount, max
global browserTopLine
set browserTopLine = validNum(browserTopLine + amount, 1, max)
return browserTopLine
end
-- ---------------------------------------------------------------
-- Handler moveScrollSquareToMatchText is called from scroll (which
-- is called when the user clicks the up or down arrows to scroll
-- the browser). It moves the scrollSquare (in sprite
-- browserScroll) to match the change in the text.
on moveScrollSquareToMatchText
global constraintScrollBar, browserTopics, browserTopLine, numVisibleLines
global browserScroll
set scrollHeight = the height of sprite constraintScrollBar
set nonZeroInteger = (the number of lines in browserTopics - numVisibleLines )
if (nonZeroInteger = 0) then set nonZeroInteger = -1
set V = ((browserTopLine) * scrollHeight) / (nonZeroInteger) + (the top of sprite constraintScrollBar)
if (browserTopLine = 1) then
set V = the top of sprite constraintScrollBar
end if
set the locV of sprite browserScroll = V
updateStage
end
-- ---------------------------------------------------------------
-- Handler setBrowserText sets the text of the onstage browser
-- (field "browser").
on setBrowserText
global browserTopLine, numVisibleTopics, browserTopics, numLinesPerBrowserEntry
global numBrowsers, currentBrowser, browserTopics, numVisibleLines
set lastLine = numVisibleLines + browserTopLine - 1
set browserText = line browserTopLine to lastLine of browserTopics
set the text of cast "browser" = browserText
put EMPTY into line (lastLine + 1) of cast "browser"
end
-- ---------------------------------------------------------------
-- Handler setFieldText sets the text of the given field ("browser" or
-- "Displayed Text")
-- make this unique to the browser field
on setFieldText scrollField, topLine, numVisibleLines, allText
set the text of cast scrollField = line topLine to (numVisibleLines + topLine - 1) of allText
put EMPTY into line (numVisibleLines+1) of cast scrollField
end
-- ---------------------------------------------------------------
-- Handler displayKeyLineAtTop is used when the user scrolls by
-- typing a key. It displays at the top of the onstage field
-- "browser" the first line of field "browserTopics" that begins
-- with the letter the user typed.
on displayKeyLineAtTop
global numberTopics, browserTopics, browserTopLine, numVisibleTopics
global browserScroll, alphabetTopicStarts
global numVisibleLines, mode
-- clearDatabase
unhiliteClickedTopic
set whichKey = the key
set charNumber = charToNum(whichKey)
set numLines = (the number of lines in browserTopics) - numVisibleLines
if (charNumber = 30) then -- up arrow key
scroll(0, -1, numLines)
else if (charNumber = 31) then -- down arrow key
scroll(0, 1, numLines)
else if ("abcdefghijklmnopqrstuvwxyz" contains whichKey) then
set charNumber = charToNum(convertToLower(whichKey))
-- get the line number of the first browser line beginning with the key pressed
if (mode = "index") then
set browserTopLine = value(item 2 of line (charNumber - 96) of alphabetTopicStarts)
else if (mode = "media") then
set browserTopLine = value(item 3 of line (charNumber - 96) of alphabetTopicStarts)
end if
set NumRemain = numberTopics - (browserTopLine)
-- what is the following if statment for?
-- if (NumRemain < numVisibleTopics) then
-- set browserTopLine = numberTopics + 1 - numVisibleTopics
-- end if
setBrowserText
moveScrollSquareToMatchText
end if
end